package org.example.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.domain.entity.Brand;
import org.example.mapper.BrandMapper;
import org.example.service.BrandService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BrandServiceImpl implements BrandService {
    @Resource
    private BrandMapper brandMapper;
    @Override
    public Map<String,Object> getBrandList(Integer page,Integer limit) {
        Map<String,Object> result = new HashMap<>();
        Page<Brand> pageResult = PageHelper.startPage(page, limit);
        brandMapper.selectList(null);
        List<Brand> brands = pageResult.getResult();
        result.put("brands",brands);
        result.put("total",pageResult.getTotal());
        return result;
    }
}
